# 创建一个模块班级模块mym2，并在该模块中做以下事情：
# 创建班级1的实例，其中班级1的成绩： cj=[50,90,89,70,89,78]，其他值自定义即可）
# 属性：班级名称cls_name，班级人数cls_num，班级类型cls_type，班级成绩cls_cj
from cym1 import Cls


class Cls1(Cls):
    # pass
    cls_name = "2212"
    csl_num = "55"
    cls_type = "2"
    cls_cj = [50, 90, 89, 70, 89, 78]

    def wRite(self, f, m, s, isUtf=False):
        if isUtf == True:
            with open(f, m, encoding='utf-8') as ff:
                ff.write(s)
        else:
            with open(f, m) as ff:
                ff.write(s)


class Cls2(Cls):
    cls_name = "2212"
    cls_num = '55'
    cls_type = '2'
    cls_cj = [40, 90, 100, 70, 69, 77]

    def wei(self, f, m, s, isUtf=False):
        if isUtf == True:
            with open(f1, m, encoding='utf-8') as ff:
                ff.write(s)
        else:
            with open(f1, m) as ff:
                ff.write(s)


if __name__ == '__main__':
    d = Cls1()
    e = Cls2()
    # print(d.fen())
    # print(d.pingjun())
    # print(d.cha())
    # print(e.fen())
    # print(e.pingjun())
    # print(e.cha())
    f = r"D:\2501\cym\dates\cls1.txt"
    f1 = r"D:\2501\cym\dates\cls2.txt"
    ss = d.cls_name + '\n' + d.csl_num + d.cls_type + str(d.cls_cj)
    d.wRite(f, "a", ss, True)
    dd = e.cls_name + e.cls_type + e.cls_num + str(e.cls_cj)
    e.wei('f1', 'a', dd, True)

# 19、
# 在17题的基础上，分别将班级1的内容写入到cls1.txt，cls2.txt中，然后再读取打印出来
# 要求：整个过程中若出现异常，需要捕获异常，并将异常信息打印到日志文件中，无异常需打印出：无异常发生
# 不管是否发生异常，均打印出：我进行异常捕获了!
